package com.epam.ws.anatomist.log;

import org.w3c.dom.Document;

import com.epam.ws.anatomist.message.MessageConverter;

public class Logger
{

	private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(Logger.class);

	public static final void fatal(String message)
	{
		LOGGER.fatal(message);
	}

	public static final void fatal(String message, Throwable t)
	{
		LOGGER.fatal(message, t);
	}

	public static final void error(String message)
	{
		LOGGER.error(message);
	}

	public static final void error(String message, Throwable t)
	{
		LOGGER.error(message, t);
	}

	public static final void debug(String message, Throwable t)
	{
		LOGGER.debug(message, t);
	}

	public static final void warn(String message, Throwable t)
	{
		LOGGER.warn(message, t);
	}

	public static final void info(String message, Throwable t)
	{
		LOGGER.info(message, t);
	}

	public static final void database(String message, Throwable t)
	{
		LOGGER.log(LoggerLevel.DATABASE, message, t);
	}

	public static final void database(String message)
	{
		LOGGER.log(LoggerLevel.DATABASE, message);
	}

	public static final void warn(String message)
	{
		LOGGER.warn(message);
	}

	public static final void info(String message)
	{
		LOGGER.info(message);
	}

	public static final void operation(String message)
	{
		LOGGER.log(LoggerLevel.OPERATION, message);
	}

	public static final void debug(String message)
	{
		LOGGER.debug(message);
	}

	public static void shutdown()
	{
		org.apache.log4j.LogManager.shutdown();
	}

	public static <T> void storeXmlObject(T pojoMessage)
	{
		LOGGER.log(LoggerLevel.XML, MessageConverter.convertPojoToXmlAndFormat(pojoMessage));
	}

	public static void storeXmlObject(Document documentMessage)
	{
		LOGGER.log(LoggerLevel.XML, MessageConverter.convertDocumentToXml(documentMessage));
	}

}
